var idTopico = "";
var idComentario = "";
var idForo = "";

var viewDetail = function(id_Topico, id_foro) {
	$.ajax({
		url : 'loadTopic', // action to be perform 
		type : 'POST',
		data : {
			id : id_Topico,
			idForo : id_foro
	
		},
		dataType : 'html',
		success : function(html) {
			$('#contenidoInformacion').html(html);
			
		},
		error : function(xhr, ajaxOptions, thrownError) {
			alert('An error occurred! ' + thrownError);
		},
	});
};


var popUpFiles = function(id_Topico, id_Comentario, idForo) {

	asignarIds(id_Topico, id_Comentario, idForo);
	$('#adjuntos').bPopup({
          onClose: function() {
        	  $.ajax({
        			url : 'loadTopic', // action to be perform 
        			type : 'POST',
        			data : {
        				id : id_Topico,
//        				idForo : id_foro
        		
        			},
        			dataType : 'html',
        			success : function(html) {
        				$('#contenidoInformacion').html(html);
        				
        			},
        			error : function(xhr, ajaxOptions, thrownError) {
        				alert('An error occurred! ' + thrownError);
        			},
        		});
           }
   });

	
};


var asignarIds = function(id_Topico, id_Comentario, idForo) {
	$.ajax({
		url : 'saveIds', // action to be perform 
		type : 'POST',
		data : {
			idTopico : id_Topico,
			idComentario : id_Comentario, 
			idForo : idForo
	
		},
		dataType : 'html',
		success : function(html) {
			console.log('id asignados... .l.');
		},
		error : function(xhr, ajaxOptions, thrownError) {
			alert('An error occurred! ' + thrownError);
		},
	});
};

var insertReplay = function(id_Topico, id_Comentario, id_firstReply, id_foro) {
	idTopico = id_Topico;
	idComentario = id_Comentario;
	idForo = id_foro;
	$('#buscar').bPopup({
		onOpen: function() {
			$('#buscar').append("<div class=\"wrapper\">");
			$('#buscar').append("<h1>Insert Comment</h1><br />");
			$('#buscar').append("<textarea id=\"txtArea\" class=\"txtArea\"> </textarea><div>"); 
			$('#buscar').append("<p class=\"name-help\">Please enter your comment.</p></div>");
			$('#buscar').append("<input type=\"submit\" class=\"submit\" onclick=\"saveReply()\" value=\"Submit\"></div>");
		},
		onClose: function() { 		
			$('#buscar').empty();
			$('#buscar').remove();
			$('#buscar').bPopup().hide();
// 			alert("esta mamada no funciona");	
		}
	});	 
};

var saveReply = function(){
	$.ajax({
		url : 'saveReply', // action to be perform 
		type : 'POST',
		data : {
			idTopico : idTopico,
			idComentario : idComentario,
			idForo : idForo,
			reply : $('#txtArea').val(),

		},
		dataType : 'html',
		success : function(html) {
			$('#buscar').bPopup().close();
			cargaInfo();
		},
		error : function(xhr, ajaxOptions, thrownError) {
			alert('An error occurred! ' + thrownError);
		},
	});
};

var displayImg = function(urlImg) {

//		$('#imagesComment').bPopup();
//		
	 
	 $('#imagesComment').bPopup({
            content:'image', //'ajax', 'iframe' or 'image'
            contentContainer:'.content',
//	            loadUrl:"http://www.kn-portal.com/fileadmin/user_upload/documents/road_rail/images/Overland_Campaign/KN-PharmaChain-with-timestamp.png"
            loadUrl: urlImg
        });
           
	 
	 $("#imagesComment").css("width", "860");
	 $("#imagesComment").css("height", "680");
           


};


